package com.lzw.mapper.superAdmin;

import com.lzw.pojo.Admins;
import com.lzw.pojo.SuperAdmins;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AdminManageMapper {

    List<Admins> list(@Param("name") String name, @Param("phone") String phone);

    void delete(@Param("ids")List<Integer> ids);

    @Select("SELECT COUNT(*) FROM pharmacymanagement.admins WHERE name = #{name}")
    int countByName(String name);

    @Select("SELECT COUNT(*) FROM pharmacymanagement.admins WHERE username = #{username}")
    int countByUsername(String username);

    @Select("SELECT COUNT(*) FROM pharmacymanagement.admins WHERE phone = #{phone}")
    int countByPhone(String phone);

    @Insert("INSERT INTO pharmacymanagement.admins (name, username, password, phone, email) " +
            "VALUES (#{name}, #{username}, #{password}, #{phone}, #{email})")
    void add(Admins admins);

    @Select("SELECT * from pharmacymanagement.admins WHERE admin_id = #{id}")
    Admins getAdminById(Integer adminId);

    void update(Admins admins);
}
